package com.allwees.core.common.util;

import org.apache.commons.lang3.StringUtils;

public class StringUtil extends org.apache.commons.lang3.StringUtils{

    private static final String UNDERLINE = "_";

    public static String humpToSeparate(String param) {
        if (StringUtils.isBlank(param)) {
            return "";
        }
        int len = param.length();
        StringBuilder sb = new StringBuilder(len);
        sb.append(param.charAt(0));

        for (int i = 1; i < len; i++) {
            char c = param.charAt(i);
            if (Character.isUpperCase(c)) {
                sb.append(UNDERLINE);
            }
            sb.append(c);
        }
        return sb.toString().toLowerCase();
    }

    public static String[] splitToArray(String str) {
    	return StringUtils.isBlank(str) ? new String[0] : str.split(",");
    }

    public static boolean containsAnyIgnoreCase(String key, String... arr) {
    	for(String s : arr) {
    		if(StringUtils.containsIgnoreCase(key, s)) {
    			return true;
    		}
    	}
    	return false;
    }
}
